* Multiproduct Firms, Horizontal Mergers, and International Trade
* Jackie M.L. Chan, Michael Irlacher, and Michael Koch

* This do file runs the main regressions for domestic market outcomes.

use "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\data\regression_data_domestic.dta", clear

* Table A.10
foreach x in lnnprod {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22 if minemployee_cvrnr>=10, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A10.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

foreach x in lnnprodAT_nodup {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & ((acquirer==1 & ((nprodT>0 & d_yr<=0) | d_yr>0)) | acquirer==0), absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A10.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

foreach x in lnrev_max lnrev_med lnrev_min theil_fy lnvrdA {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22 if minemployee_cvrnr>=10, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A10.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

* Table A.16
foreach x in lnrev_max lnrev_med lnrev_min theil_fy {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 dnprod D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & (acquirer==1), absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_A16.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 dnprod D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

* Figure A.5(a)
ppmlhdfe nprod_dro p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & nprod_dro>0, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA5.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes

ppmlhdfe nprodAT_nodup p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & ((acquirer==1 & ((nprodT>0 & d_yr<=0) | d_yr>0)) | acquirer==0) & nprodAT_nodup>0, absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA5.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes

* Figure A.9(a) and (b)
foreach x in lnnprod {
areg `x' p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & ((acquirer==1 & d_yr<1) | acquirer==0), absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA9.txt", keep(p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

foreach x in lnnprodAT_nodup {	
areg `x' p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & ((acquirer==1 & d_yr<1 & ((nprodT>0 & d_yr<=0) | d_yr>0)) | acquirer==0), absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA9.txt", keep(p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

foreach x in theil_fy {
areg `x' p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & ((acquirer==1 & d_yr<1) | acquirer==0), absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA9.txt", keep(p4S p3S p2S p1S test m1S m2S m3S m4S D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

* Figure A.18
merge 1:1 cvrnrA aarA using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\data\temp_exports_all_cvrnr.dta", keep(match master) keepusing(vrdA) nogen

merge 1:1 cvrnrA aarA using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\data\temp_vars_com_all_cvrnr.dta", keep(match master) nogen

gen lnvrdA_dom_dro = ln(vrdA_dom_dro)
gen lnvrdA_exp = ln(vrdA)
gen lnvrdA_vars = ln(vrdA_vars)

foreach x in lnvrdA_vars lnvrdA_dom_dro theil_fy_vars theil_fy_dro {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & theil_fy_dro!=., absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA18.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

drop theil_fy_vars

* Figure B.4(a)
gen lproductivity = ln(XVT_FIRM/employee_cvrnr)
gen lsalespw = ln(OMS_FIRM/employee_cvrnr)

foreach x in lproductivity lsalespw {
areg `x' p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22 if minemployee_cvrnr>=10 & lnnprod!=., absorb(cvrnrA) cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureB4.txt", keep(p4 p3 p2 p1 test m1 m2 m3 m4 D_AA_1-D_AA_22) bdec(4) sdec(4) nocons nonotes
}

* Figure A.10 
foreach x in lnnprod {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=10, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA10.txt", bdec(4) sdec(4) nocons nonotes
}

foreach x in lnnprodAT_nodup {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=10 & ((acquirer==1 & ((nprodT>0 & d_yr<=0) | d_yr>0)) | acquirer==0), fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(500) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA10.txt", bdec(4) sdec(4) nocons nonotes
}

foreach x in lnrev_max lnrev_med lnrev_min theil_fy {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=10, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA10.txt", bdec(4) sdec(4) nocons nonotes
}

* Figure A.12(c) and (d)
foreach x in lnnprod {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=10 & minnprod>1, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA12.txt", bdec(4) sdec(4) nocons nonotes
}

foreach x in lnnprodAT_nodup {	
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=10 & minnprod>1 & ((acquirer==1 & ((nprodT>0 & d_yr<=0) | d_yr>0)) | acquirer==0), fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(500) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA12.txt", bdec(4) sdec(4) nocons nonotes
}

foreach x in theil_fy lnrev_max lnrev_med lnrev_min {
did_imputation `x' group_cvrnr aarA aar3 if minemployee_cvrnr>=10 & minnprod>1, fe(group_cvrnr aarA) hor(0/2) pretrend(4) tol(0.0001) maxit(250) autosample cluster(ind)
outreg2 using "D:\Data\Workdata\703989\FJSJ3989\CIK\replication_restat\output\table_figureA12.txt", bdec(4) sdec(4) nocons nonotes
}
